package com.gs.wzweather.dao;

import com.gs.wzweather.dao.mapper.ForeDayMapper;
import com.gs.wzweather.entity.DSBean;
import com.gs.wzweather.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/11/22 0022
 */
@Repository
public class ForeDayDao {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    ForeDayMapper mapper;

    public List<DSBean> queryChannelFore(String station){
        try {
            Map<String,String> map = DateUtil.getYearMonthYesterday();
            String time = map.get("year")+map.get("month")+map.get("day");
           return mapper.queryChannelForeByStation(station,time);
        } catch (Exception e) {
            logger.info("queryChannelFore->{}",e.getMessage());
            return null;
        }
    }

    public List<DSBean> queryPortFore(String station){
        try {
            Map<String,String> map = DateUtil.getYearMonthYesterday();
            String time = map.get("year")+map.get("month")+map.get("day");
            return mapper.queryPortForeByStation(station,time);
        } catch (Exception e) {
            logger.info("queryPortFore->{}",e.getMessage());
            return null;
        }
    }

}
